﻿using RRKAutohaus.Core.EntityFramework.Configuration;
using RRKAutohaus.Model;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RRKAutohaus.Core.EntityFramework
{
    public class RRKAutohausDbContext: DbContext
    {
        public RRKAutohausDbContext()
            : base("DefaultConnection") { }

        //declaration of models to be created and serve as containers for the database
        public DbSet<Car> Car { get; set; }
        public DbSet<Specification> Specification { get; set; }
        public DbSet<Video> Video { get; set; }
        public DbSet<Image> Image { get; set; }
        public DbSet<Blog> Blog { get; set; }
        public DbSet<Category> Category { get; set; }
        public DbSet<Comments> Comments { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            //add configuration for the model
            //this will set up the relationships for the tables
            modelBuilder.Configurations.Add(new VideoConfig());
            modelBuilder.Configurations.Add(new ImageConfig());
            modelBuilder.Configurations.Add(new CategoryConfig());

        }
    }
}
